package com.fenghongzhang.day005;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

public class ActivityToFG extends AppCompatActivity {
    private EditText etId;
    private Button buttonId;
    private LinearLayout linearLayoutId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_to_f_g);


        etId = (EditText) findViewById(R.id.et_id);
        buttonId = (Button) findViewById(R.id.button_id);
        linearLayoutId = (LinearLayout) findViewById(R.id.linear_layout_id);

        /**
         * setArguments();
         * getArguments()
         */
    }

    public void click(View view) {
        String string = etId.getText().toString();
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
        ContentFragment contentFragment = new ContentFragment();

        Bundle bundle = new Bundle();
        bundle.putString("input",string);
        contentFragment.setArguments(bundle);

        //把老的替换掉
        fragmentTransaction.replace(R.id.linear_layout_id,contentFragment);
        fragmentTransaction.commit();

    }
}
